<template>
  <el-dialog
    :visible="isShow"
    title="点位详情"
    :close-on-click-modal="false"
    @close="closeDialog"
  >
    <table-component :table-cols="tableCols" :table-data="tableData" />
  </el-dialog>
</template>

<script>
import TableComponent from '@/views/point/components/TableComponent.vue'
import { nodeDetail } from '@/api/pointManage/point'
// import { parseTime } from '@/utils/index'
export default {
  name: 'DiaweiDetailDialog',
  components: {
    TableComponent
  },
  data () {
    return {
      isShow: false,
      tableCols: [
        { label: '序号', type: 'index', width: '100px' },
        { label: '机器编号', prop: 'innerCode' },
        { label: '设备状态', prop: 'vmStatus' },
        { label: '最后一次供货时间', prop: 'lastSupplyTime' }
      ],
      tableData: []
    }
  },
  methods: {
    async openDialog (id) {
      const res = await nodeDetail(id)
      console.log(res)
      res.forEach(item => {
        if (item.vmStatus === 0) {
          item.vmStatus = '未投放'
        } else if (item.vmStatus === 1) {
          item.vmStatus = '运营'
        } else {
          item.vmStatus = '撤机'
        }
        const date = item.lastSupplyTime
          .replace(/\-/g, '.')
          .split('T')
          .join(' ')
        item.lastSupplyTime = date
      })
      this.tableData = res
      this.isShow = true
    },
    closeDialog () {
      this.isShow = false
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  width: 630px;
  border-radius: 16px;
}
</style>
